import { useIntersectionObserver } from '@vueuse/core'
import { ref } from 'vue'
export const useLazyData = (fn) => {
  const target = ref(null)
  const { stop } = useIntersectionObserver(
    // dom
    target,
    // 监听的回调函数
    ([{ isIntersecting }], observerElement) => {
      console.log(isIntersecting, 222222)
      if (isIntersecting) {
        stop()
        // 获取数据
        // getNew()
        // if (fn) {
        //   fn()
        // }
        fn && fn()
      }
    }
  )

  return target
}
